package com.zyzd.general.module.card;

import android.support.v7.widget.AppCompatSeekBar;
import android.support.v7.widget.CardView;
import android.widget.SeekBar;
import android.widget.TextView;

import com.zyzd.commontools.utils.DeviceUtil;
import com.zyzd.general.R;
import com.zyzd.general.adapter.OnSeekBarChangeAdapter;
import com.zyzd.retrofit.base.BaseFragment;

import butterknife.BindView;

/**
 * Created by lzy on 2018/5/15 0015.
 * description ${CardView 案例
 */
public class CardViewFragment  extends BaseFragment{

    @BindView(R.id.cardView)
    CardView mCardView;
    @BindView(R.id.seekbar_1)
    AppCompatSeekBar mSeekbar1;
    @BindView(R.id.seekbar_2)
    AppCompatSeekBar mSeekbar2;
    @BindView(R.id.seekbar_3)
    AppCompatSeekBar mSeekbar3;
    @BindView(R.id.tv_1)
    TextView mTv1;
    @BindView(R.id.tv_2)
    TextView mTv2;
    @BindView(R.id.tv3)
    TextView mTv3;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_cardview;
    }

    @Override
    protected void initData() {
        mSeekbar1.setOnSeekBarChangeListener(new OnSeekBarChangeAdapter() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardView.setRadius(DeviceUtil.dpToPx(progress));
                mTv1.setText("控制圆角大小: " + progress + "dp");
            }
        });
        mSeekbar2.setOnSeekBarChangeListener(new OnSeekBarChangeAdapter() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardView.setCardElevation(progress);
                mTv2.setText("控制阴影大小: " + progress + "dp");
            }
        });
        mSeekbar3.setOnSeekBarChangeListener(new OnSeekBarChangeAdapter() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                mCardView.setContentPadding(progress, progress, progress, progress);
                mTv3.setText("控制图片间距: " + progress + "dp");
            }
        });

        mSeekbar1.setProgress(20);
        mSeekbar2.setProgress(20);
        mSeekbar3.setProgress(0);
    }

    public static CardViewFragment getInstance() {
        return new CardViewFragment();
    }
}
